package com.example.text.ui.mall.model



import android.content.Context
import android.graphics.drawable.Drawable
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.UnderlineSpan
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.entity.MultiItemEntity
import com.example.text.R


object ClubHomeRowTypes {
    const val TITLE = 1

    //广告栏
    const val AD_BANNER = 2
    const val TAB = 3

    //推荐俱乐部
    const val CLUB = 4

    //推荐活动
    const val ACTIVITY_BANNER = 5

    //推荐骑行组队
    const val DRIVING_GROUP = 6

    //推荐动态
    const val DYNAMIC = 7
}

/**
 *
 * 俱乐部主页Item
 * */
class ClueHomeFormItem(
    var type: Int,
    var title: String? = null,
    var titleType: TitleType? = null,
    var tabs: ArrayList<ClubHomeTabItem>? = null,
    var banners: ArrayList<MallBanner>? = null,
    var clubs: ArrayList<ClubRecommendItem>? = null,
    var activities: ArrayList<ClubActivityRecommendItem>? = null,
    var drivingGroup: ClubDrivingGroupRecommendItem? = null,
) : MultiItemEntity {

    enum class TitleType {
        CLUB,ACTIVITY,DRIVING_GROUP, DYNAMIC
    }

    override val itemType: Int
        get() = type

    fun requireTitleText(context: Context): Drawable? {
        return when (titleType) {
            TitleType.CLUB -> ContextCompat.getDrawable(context, R.mipmap.icon_text_club_recommend)
            TitleType.ACTIVITY -> ContextCompat.getDrawable(context, R.mipmap.icon_text_activity_recommend)
            TitleType.DRIVING_GROUP -> ContextCompat.getDrawable(context, R.mipmap.icon_text_driving_group_recommend)
            TitleType.DYNAMIC -> ContextCompat.getDrawable(context, R.mipmap.icon_text_dynamic_recommend)
            else -> null
        }
    }

    fun requireMoreTextSpan(): CharSequence {
        val text = "查看更多"
        val spannableStringBuilder = SpannableStringBuilder("查看更多")
        spannableStringBuilder.setSpan(UnderlineSpan(), 0, text.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
        return spannableStringBuilder
    }
}

data class ClubHomeTabItem(
    var icon: Int,
    var tabName: String
) {
    fun requireIcon(context: Context) = ContextCompat.getDrawable(context, icon)

}

/**推荐俱乐部*/
data class ClubRecommendItem(
    var clubId: String? = null,
    var cover: String? = null,
    var name: String? = null,
    var memberNum: Int? = null,
) {

    fun requireMemberNum(): String {
        return (memberNum ?: 0).toString()
    }
}


/**推荐俱乐部活动*/
data class ClubActivityRecommendItem(
    var activityId: String? = null,
    /**活动封面*/
    var cover: String? = null,
    /**活动名称*/
    var activityName: String? = null,
    /**报名时间*/
    var signUpDate: String? = null,
    /**报名人数*/
    var signUpMemberNum: Int? = null,
    /**渠道 官方/其他*/
    var channel: Int? = null
) {

    fun requireSignUpMemberNum(): String {
        return String.format("%d人报名", signUpMemberNum ?: 0)
    }
}

/**推荐骑行组队*/
data class ClubDrivingGroupRecommendItem(
    var groupId: String? = null,
    /**活动封面*/
    var cover: String? = null,
    /**组队名称*/
    var drivingGroupName: String? = null,
    /**组队报名时间*/
    var drivingGroupDate: String? = null,
    /**组队报名人数*/
    var signUpMemberNum: Int? = null,

    var last: Boolean = false
) {

    fun requireSignUpMemberNum(): String {
        return String.format("%d人已参与", signUpMemberNum ?: 0)
    }
}
object FormRowId {
    const val ID_EMPTY = "ID_EMPTY"
    const val ID_NEED_PAY = "ID_NEED_PAY"
    const val ID_NEED_SAFE = "ID_NEED_SAFE"
    const val ID_AMOUNT = "ID_AMOUNT"
    const val ID_POI_ADDRESS = "ID_POI_ADDRESS"
    const val ID_POI_ADDRESS_START = "ID_POI_ADDRESS_START"
    const val ID_POI_ADDRESS_END = "ID_POI_ADDRESS_END"
    const val ID_DATE = "ID_DATE"
    const val ID_DATE_TIME = "ID_DATE_TIME"
    const val ID_BANNER = "ID_BANNER"
    const val ID_COVER = "ID_COVER"
    const val ID_AVATAR = "ID_AVATAR"
    const val ID_NAME = "ID_NAME"
    const val ID_SIZE = "ID_SIZE"
    const val ID_USER_NAME = "ID_USER_NAME"
    const val ID_PHONE = "ID_PHONE"
    const val ID_DESC = "ID_DESC"
    const val ID_MOTO_BRAND = "ID_MOTO_BRAND"
    const val ID_GENDER = "ID_GENDER"
    const val ID_SMS_CODE = "ID_SMS_CODE"
    const val ID_ADD_POINT = "ID_ADD_POINT"
    const val ID_REMOVE_POINT = "ID_REMOVE_POINT"
    const val ID_TIME_PICKER = "ID_TIME_PICKER"
    const val ID_TIME_PICKER_2 = "ID_TIME_PICKER_2"
    const val ID_AUDIT_MODIFY = "ID_AUDIT_MODIFY"
    const val ID_AUDIT_REJECT = "ID_AUDIT_REJECT"
    const val ID_TYPE = "ID_TYPE"

    // MALL
    const val ID_POST_CODE = "ID_POST_CODE"
    const val ID_AREA_SELECTOR = "ID_AREA_SELECTOR"
    const val ID_DETAILED_ADDRESS = "ID_DETAILED_ADDRESS"
    const val ID_GOODS_OPTIONS = "ID_GOODS_OPTIONS"
    const val ID_GOODS_ATTRIBUTE = "ID_GOODS_ATTRIBUTE"
    const val ID_DISTANCE = "ID_DISTANCE"
    const val ID_SWITCH = "ID_SWITCH"

}

